Added EADDRINUSE error handling, moved registration of output handler to the .listen callback