Bunches of fixes. Not very atomic, my bad.