Fix some issues around Hibernate session

And some fix of VariableChecker