Fix issue with double-encoding certain values. A test is needed for this, but unsure how to test it simply