a little bit of refactoring and cleanup for release.