added logout action
some memory usage fixes