Added more code comments and some minor fixes.