Refactoring on lock management inside resources.