Structure and mutual transformations of anhydrous and hydrous CsMgPO4