big refactor, implement low level client