Fixed bugs with deferred instantiation, and other things