Add locking to API methods