Create a server class

Preserving the original functionality, decouple server business logic from UI logic and gather server functionality into a reusable Server class. This should be functionally equivalent of what was there before.

Next I'd like to move this class into its own .ts file and continue to work on the TODO items, assuming you like these changes and want me to continue down this road...

-Grimmlet
Dedent some of the whitespace in this fail callback