improved typing and failure modes of tensor() for states, wrote some docs