Code clean up and reorganization.