The last two conditionals in loop() are still inside the Serial.available()
test, so they will never be noticed except if a character comes in off the
Serial port.
You need to move them up a level so they always get tested round loop()
Also loop() is simply too long to read - put the various parts of it in subfunctions
so its readable... Always a good idea to increase readability and maintainability
of code - if a function is larger than a page, its probably too big.