patch from Phillip (Mantis #814)