Renames functions and slight refactoring.