Refactoring / optimizing gl calls