Two patches, three issues

I'm inspecting this code as I write my own badge application and trying to patch issues I think I see, so the patches may be out in left field.