Finished lookup-table search. Left some debug lines commented as 'DEBUG'.