Various bits of code cleanup