added xml docs and fixed some code issues