implemented replace() in Resourcemanager and use mutex locks more consequently