Compiler suggested fixes applied and added some comments