minor refactoring and cleanup
more code cleanup and simplification