Numerous bugfixes on the recently added code detection feature.