Reducing code duplication and debug mode notices

I just added some code to reduce the duplicate code in `is_us()` and `is_country()` and added a bunch of `isset()` calls when checking `$_SESSION`.