Problems in Stabilisation of autonomous Quadcopter

The following code which is meant to stabilize the quadcopter is not working fine . Please suggest few changes in the code so that PID will work smoothly or you are always welcome if you wanna suggest a totally new method to stabilize the quadcopter using just Gyroscope and Accelerometer which stabilizes the quad in a given plane . For now I am not concentrating on height stabilization (which can be done by ultrasonic sensors) . So please suggest something to stabilize the quadcopter in a given plane . Please find the code as attachment to this post .

sketch_jul17_somethin_dat_runs.ino (8.52 KB)