Cleanup and a few fixes