Add comments, clean up the code
Add more comments to clarify the process
Small tweaks and comments