File clean up, code edit, added comments