Cleaned up some debug code and tied some loose ends.