Cleanup and minor fixes