Type errors much better now, also documentation added