Removing debugging, handling KeyError