Gpu rendering

This fixes various issues with the GPU rendering path.