Fix typos
Refactor data structures, fix crf weighting: use discrete time events instead of actual time
Fix sorting and switching threshold