Fix transaction in progress error.
Fix potential null pointer exception.