A few bugfixes here and there, not the best commit message I know