Added command line argument, separated gen logic, added/modified interfaces.