Code cleanup - codegen.py: Separate line parsing logic to a class. Make parsed tree more simple form to handle. And some improvements.