A bunch of fixes