Adjust locking based on suggestions by @t3hk0d3
Use only names for autocompletion and add # prefix to use exact name

Fixes #1062
Fixes #1088