Reduce redundancy, make hacky fix even more hacky, other bug fixes

But hey, it works!