Refactoring to tighten things up and put in better names