Fix bug where KeyGenerator would result in a JS error if the class was nested