Added self attribute to lock() and unlock()