Large bug correction batch

Slowly making it work, including the new code discovery option.