memory dump
simplify code
put the key allocation in the dictionary

... simplify code and speed things up.