Refactoring to enable resusable components between standalone server and server on the device.