code reorganization; markov chain debugging