Server refactoring.

Nice and clean.