Pull concrete implementations out into interfaces and classes

I did a lot of the foundation work for making the software easier to test and implementing Guzzle into the system later on. I strived to make the changes all 100% compatible with the current implementation (I have also left in bugs in the software that I found)

I know there is a composer pull request waiting to be merged, and I can revise this commit to include it before it is pulled in.

As of the moment, all classes are defined in the main php file.

**None of the code has been tested!**