Adds statement ref validation to fix #280.
Improves debugging.
Merge pull request #314 from LearningLocker/issue-280

Adds statement ref validation to fix #280.