Changed to api handler and added ref to running server so it could be started and stopped