Commenting added and general look of the code cleaned up