Unstable when executing library?

So what is wrong with code that only you can see will mean I have to have mind reading powers, which lucky for you I do.
You need to remove all the delays from your code and re write it as a state machine. One example of a state machine is given in the blink without delay example in the arduino IDE.
Or you can read this:-
http://www.thebox.myzen.co.uk/Tutorial/State_Machine.html