added timebased opening, better logging to mongodb