code review and minor improvements