Memory leaks fixed, Valgrind still outputs some leaks but it seems to be in the driver(it points only to OpenGL calls, all of them are properly freed)