Refactor defined methods to use more efficient array slicing
Refactor loop to use a method object
Move write_node to base emitter