clean up and better dictionary generation