added comments and other small changes
added more comments