Added check to ensure the correct code was found

This really wasn't an issue, but there is no reason (that I know of) not
to perform this check.
Various changes to code grant/revoke mostly

Completely rewrote advanced grant and revoke to ensure quality, remove
pointless code, and generally create better code.
Fixed a few missed UI elements from previous updates.