The model generating speed may become slightly slower than the previous version because of the extra checks. This closes #1, and closes #3