Lots of changes following some fundemental changes by the dev team for gaia. Also added test 39.