Refactored code and set base for serialization of objects