Fix declare-fun/define-fun in dumps; resolves bugs 408 and 385