Handling of creating keys and locks