Refactored unit of work & session.
Minor fixes.