Lazy initialization of extptr structs (need for correct serialization)

We have spoken about it. For correct serialization we need lazy initialization for ext-pointer objects (like hmat). 

I implemented it. Also it takes us more beautiful and compact code.