Code cleanup/reorganization