Decoupled functions from records.
Some code clean up.