Refactor all functions.