Making the code readable

More cleanup and more comments