clean up code blocks, and add extra explanations