refactor and tweaks to servery