Restructure all the rx code