Manually applying changes in https://github.com/joomla/joomla-cms/pull/5...

Manually made the changes in http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=29596 as the existing pull request fails to apply to the 2.5.x branch