Adds logging; fixes inexhaustive pattern match.