Incorporated changes from r-gaia-cs and davis68