Minor code cleanup; should produce better error message for #354