Bulk of changes from !265
These are the cleanups and fixes from !265 (merged) without adding new functionality. Would be nice to have this applied since it fixes a real crash on cleanup. If this looks to cumbersome i can drop the last patch Make renderer a GObject
and move that to !265 (merged).