Refactored long functions.