Wrap server in a separate class

Start wrapping functionality in a class so that we can get rid of the
global variables we're using.

Signed-off-by: Marcus Karlsson <mk@acc.umu.se>