Fix bugs in linear state-space model