Of course I messed up the merge completely. This commit should hopefully fix most of it.