Improve client db

this adds the functionality mentioned in #7 
isn't  `allowed_keys[key] is not None` redundant? your first if checks for this