cleaning up code and session factory creation