fixed a bunch of bugs, added xml reading