Update tests, docs and code.
Still needs to fix some TODO though