I have this problem quite often when doing technical uphill trails with roots and rock to climb over. When I lean forward, the rear tire looses traction and spins, and when I lean back the font wheel lifts up. The problem is called "inexperience"; the solution, "RIDE".