code review and cleanup