apply patch from alexmmm