Add locks, implement session releasing