add realtimeEmit
fixed midnight db bugs
Added dynamic history checker