improved lock 'if' header parsing and Not clause handling