Start of pinhole optimiser. Minor fix for debugger.