Added some messages to the script, handled some more edge cases, and added
some comments.