Interesting things

Fixes a bunch of things. Based on fixes I did in fredrik.

r?