Squash some bugs.
Add some debugging logging.