Added comments, removed some calls to "console".