Added locking for loading rules