Factor out the texture rendering and delete unnecessary layer types.
Add flipping and modernize the codebase a bit