Set up quite a lot of the functionality of the active record stuff