Add some code comments and code cleanup