Added a bunch of comments to clarify structure of application and implementation details.