minor fixes and code cleanup