Cleaned up the code

Made everything easier to read. No changes in the terms