adopting changes made in mangrove-server
merging over more stuff from mangrove-server