More clean up, small issues and optimizations