Prerequisite Initial Commit

Initial commit of the prerequisite functionality. Still needs extensive
bugfixing and testing, but kind of sort of works just not very cleanly.