Cleanup and some fixes