Cleaned up code in markov.py