Cleanup and a couple of fixes