Separated the code into stages and started putting code inline in the article.