Minor cleanups, movements of code, and removal of old/commented code.