Changes to session; added mutex locks; other small changes