Code cleanup and improvements in compiler logic. Few more extension points added. (#446)