add constraints to fm; fix several type errors