Probably going to pull this out into separate files soonish, it's getting a bit long. Just grouping for now though.