Refactored code a bit for a better naming scheme.