Various changes and fixes (yeah really specific, I know)