Check for lock before processing commands for locking

Cuts time of spec of lock -> unlock in half.

Also replace spinlock with a channel.