Cleaned up return handler and listener functions.