code review and other minor fixes