Fix allowing no code to be set, as noticed by Matthew Somerville