Cleaned some of the code