Make arg/3 generate values on backtracking as well

Also limited unnecessary deep dereferencing in functor/3 and
atom_chars/2.
Add BIP atom_codes/2