fixed cleanup code for outbox and fixed bugs related to app crashing when user log out