Added safeguards

Mainly checking for unset values, but also sanitizing $_GET values.