Add new state structure, tidy up old RF code