This is based on a patch send by Nathan Hintz <nlhintz@hotmail.com> SVN-Revision: 34997
This was party inspirited by patches send by Nathan Hintz <nlhintz@hotmail.com> SVN-Revision: 34989