Pushed basic implementation of locks.

Many bugs.