some cleanup, minor refactoring