Numerous changes to suit running on the server