Added check to prevent running SQL stuff unless all required variables are non-false. Closes #202