Improved messages types

Now the objects are correctly instantiated with the right types