Added ShaderManager, cleaned up some code and fixed a couple of memory leaks