Fix conditionals
Add more debugging
Fix key being set to nil if it doesn't contain '::'.

gsub returns nil if no replacements are made, so the key was getting set to nil if it did not contain '::'.