Make `StatEvent` a class and improve it.
Move `StatEvent` to a separate file.