some cleanup
More cleanup and reorganization.