Added lots of implementation notes in the comments.