Split the main markov file up based on functions and used require method to maintain functionality. Also chunked out methods a little further and updated comments and var names for clarity.