Fixed metadata serialization
added trusted hosts check