Fixed extra stop condition and added comments

This currently works with the examples.