Minor reorganization and code clean-up