fixed more output ordering bugs, removed redundant code