Updates to criteria and bug fixes

Improve on the criteria setting.
Bug fixes