Added NAN detection helper function to mcmc.py, also general cleanup.