use free_symbols instead of atoms(Symbol) where appropriate

replaces #7272 (it is rebased over master and is_number was simplified in the last commit) and resolves #5526