Changed code for serialization to use generics instead of dynamic keyword. Adding basemodel class in.