fixes to leave functionality

fixes to leave functionality