code cleanup #253 #281 #319 #320 #321

code cleanup #253 #281 #319 #320 #321