Refactored server.

Everything is in place for communication between server and client via JSON.