Use record for state, fix export