The function check_refmap_consistency is broken (undefined variable). In addition, there is an extra '}' in the function and the indentation seems to indicate that the nested if-else clauses are not organized in the way intended. Cheers Sudhir