Started pg stuff - based on mysql engine but altered significantly.