Running this against a SQL 2016 server, I have found numerous instances where wait_description is not null and hid is null. I changed the following statement as follows:
original:
INSERT [#obct_locks]([hid],
[wait_description],
[dbid],
[associatedObjectId])
SELECT [blk].[hid],...