Misc. cleanup and minor fixes