Fix issue308 and fix (unrelated) failure to break out of nest loop.
Merge pull request #310 from ryneeverett/issue308

Fix issue308 and fix (unrelated) failure to break out of nest loop.