3.1 code refactor

Replacing lots of old 2.4 deprecated code with new 3.1 compatible code.

Will require peer review and also aware that we could take this further... for now it's just what I could find and repair.

Most issues were around the ORM style and the use of Config system vs statics.

Locally all previous tests are passing and a quick smoke tests playing around in the forum and posting some stuff seems to work as expected. More testing would be great though.
Voldemort?