Added comments, more stopping and failing criteria and some layout changes