Fix some stuff with upgrade
Finish to replace simple_hash_query and array_from_query