Fixed a generics-related bug reported in #207, hopefully without introducing a new one.