code review and fixes