Move some calculation functions to another file.
Reorganize references.