Cleaned up router code.

Added comments, documentation, and simplified functions.

Note that the add_link() method is deleted, so all code must be updated
to use add_links().