Fix dictionary update and key issues