Added some smarts, should detect the right code revision for reference.