fixed some bugs and crashes with writing data to disk
merged with design of outboxviewcontroller