Refactor and recomment invalidation procedure