Add input locking. Fixes #1