Added interface for lock and fixed bugs