refactored out ugly things.