added locking to extension and codes to lib