Some fixes to try and catch up to the latest verion of the development branch, but quite a bit of work to go