Fix GL errors due to invalid sizes.
Make sorting code less ugly. Fix config code, still needs a nice config name.