Remove element from hash before freeing key

To avoid leaving invalid memory in a hashmap remove the element
first before freeing the element when cleaning up.
Fix label memory leak on get_value
db: Handle error when allocating a db file name
Update todo
shared: get_value shouldn't always look at user layers

If layer name isn't specified get_value should only look at user layers
if there isn't a key in a system layer.