Fix a bug causing duplicate keys in storage
Some slight convienience changes for the lua API