Commented and formatted (cleaned) all the code