refactor state scoring and templates