Added comments

Added comments and modified to make a bit more readable.