Also removes some functions that are no longer used and fixes debug output where the tests found an issue.