add NPE check for TablePairFactory
add volatile for val
resolved issus #1