Some code clean up and decomposition. Added Utils class to hold global variables.