Clean and simplify redirect_uri logic
Exemption for sandboxes, better logging