Added some comments for clarity.