Refactored a few methods to make them more readable.