Fixed occasional error with class definition caching. Also changed a test to work around a JSON serialization issue.