Replace exception with check of value type. Controlled the correctness of every possible memory flag