KAFKA-307 Refactor server code to reduce interdependencies; patched by nehanarkhede; reviewed by junrao