Asserts added. Errors fixed.