Add from_state and to_state functionality, update README with example.