Base infrastructure

I'll send an email shortly explaining this code!