Refactored code to more closely follow conventions.