Add reset method and use it if the state gets invalid. - fixes #2