Various bits of cleaning up, little debugging