Compute custom_instance_class before anything else

The rest of class initialisation depends on it.