Move deserializing logic to models