Lots of comments added for clarity.