Added lock, helper functions