make smart pointers safer on cleanup
clean up lazy backward compat constructors
make Optimizers and OptimizerStates ModelObjects

This means they can have dependencies that are tracked. eg, a PDB writer can now make sure that its atoms all are up to date

close #400