Implemented locks
Merge pull request #318 from fluke777/locking

Ready to merge - Implemented locks