Remove genCodeImpl from BackEnd, and refactor