Added listen() code and further debug information