Bugfix for endless loop when creating certain keys

Signed-off-by: Dominik Schadow <dominikschadow@googlemail.com>