Fix bugs in unmarshalling