reorganize the code to reduce copypaste among multiple continuous time markov model implementations