Recognize nested classes in K

Closes #176.