Transmission?

Since you didn’t mention the clutch, I’ll assume it’s an automatic transmission. Rough shifting and slipping out of gear would indicate the transmission has problems. If it slips out of gear the engine will race because there is no load on it. The RPMs will go back to normal when it slides back into gear.