Various changes, bugfixes

Apparently I haven't resynced this in ages.