Various Fixes

This fixes things. See the commit mesages for more info.