Check for OpenGL errors
Small fixes
Ordering now matches iteration order of voxel_range

This is important for the upcoming multithreading of the terrain
generation, where multiple chunks must be locked in a consequent
order to avoid deadlocks.