Changed kwargs.pop calls to kwargs.get calls. Thanks to @ttsirkia.