Encapsulate state handling.