Cleanup and a few minor improvements