Moved method code into smaller methods.