Fix environment handling in queue listener.