rewrite ambiguous functions better. Fixes #428