server side refactor

see our conversation and the commit messages for more details