Apply patch from trac #133