General cleanup and reorganization