Moved some of the main processing around to improve readability. Added a commonMark parser and implemented the preprocessor.