Various fixes

Merging myself.