Mega commit. Stupidly didn't separate these commits.