refactor the code.

strip out gravpm to a new file. (really shall move to a utils directory.
move files around abit

gravpm -> utils.