Beautiful input file & some code enhancement