Split server into two parts

Split server initialization away from the main method. This should
reduce compile time.