Refactor functions.