Clean up and re-use code

Restructured the gfx core somewhat so we re-use code across all layer
rendering cores.