More cleanup and rearrangement