The gnats like to lay eggs up to about 2 inches of soil. IF you properly let your soil fully dry, then the gnat eggs will not survive. Shake your pot sometime, you will see the gnats come burrowing out of the soil. Believe me, that's where they came from, because they do not travel more then 8 ft. You can get Gnat-GO at any local hydroponic store. You just mix a little in some water in a spray bottle and spray the top of your soil every so often.
As far as the yellowing. IF the yellowing is occurring from the bottom to top. IF the leaves go yellow, then brown, and shrivel up. You have a nitrogen deficiency. Your plant is about to produce buds. If you keep more of the big fan leaves alive, the better bud production you will have. You definitely have a nitrogen deficiency, and Im going to guess a phosphorus, potash, phosphate, magnesium, and calcium deficient as well. As far as the PH of your water. This is the most important part of growing ANYTHING! City water can vary from 4.8 to 8.4. I have seen that big of variance. Buy yourself a PH tester off ebay for 30$ and you will never, ever have plant issues again. Guaranteed. If you have any issue it will be very easy to diagnose and very easy to correct. Believe me, it will be the best 30 bucks you will ever spend.