Did some refactoring to fix some cut and paste errors