Codebuilder

This introduces a helper struct to build code. It also has a couple fixes and a more complete unittest to help prevent me from breaking these things.