Added functions to compose and decompose state.