Locate class definition more reliably

In theory, anyway.