Adding preserveNested option, adding type checking