Server refactoring – fix #34 and #4