Many times I've written a line I really liked, only to realize (sometimes years later) that grammatically (or, as grammatically taught) it was incorrect even though it sounded right. So I'd go back and change it, but then I'd always wind up going back to the best sounding again. And that's pretty much what I go with today, what sounds the best. This always drove me crazy, though.

The Harbrace College Handbook, now published in its 13th editon by Hodges, has an entire chapter addressing this issue entitled, Agreement. Here's the url, although you have to register to get in (I have a print copy): http://www.hbcollege.com/english/comp/college/