Several things refactored.