FIX Back port of bug fixes and enhancements from silverstripe.org/forum

Selection of fixes and enhancements made on the community site, now contributed back to open source.

Could still do with some ORM code enhancements (will address in another pull request).