Clean up code, revise way to parse xml