fix a lot of bugs in gaia.