Cleaned some of Daves code