Lots of changes I should have put into individual commits but didn't