Made a few lines more readable.
Added some comments.