Use any() instead of term() in types.
Added function specifications.