restructure code, add additional checking
Implement in syncmodels + minor tweak.