fixed disappearing type field problem

and fixed some persistence bugs