Finished function refactoring.