Fix 1.6.4 compatibility

Also quite a bit of NMS reflection optimization in here.