Refactor #add_encoded

Split up the code, creating two new methods in the process.