Pulled together the changes in other forks to make a version which works with Silverstripe 3

Tested with 3.1 beta only