A little more refactoring to make things more understandable.