Some cleanup and rearranging