Dhm/opaque keys bugs

@sarina @dianakhuang fixes for 2 of the bugs found friday. No doubt, someone (probably I) should write unit tests. I reproduced the adam bug and ensured this fixed it up to the point where it couldn't find the external grader.