added some small changes for code review. Functionality looks OK to me