A bit of restructuring and cleanup