Updated the database variables to be outside of the WPDBCHECK function. This allows us to use these elsewhere much more easily. Also made sure to unset these variables.