Bugfix and added lockable version