some minor code cleanup/refactoring