Seperate server from client code.

Closes #5 and #1