We have been fighting with Gmail in Apple Mail for a good long time now and never really could understand how or why Gmail works the way it does. Now with the new Apple Mail in OSX 10.9 Mavericks, things have come to a head.
The biggest thing I want to point out is that if you have implemented the previously recommended fix of hiding your All Mail folder from IMAP in your Gmail settings, you need to go undo that “fix” before upgrading to Mavericks. And possibly not use Apple Mail to access your Gmail for the foreseeable future. Read the TidBITS article, Mail in Mavericks Changes the Gmail Equation, for a full explanation.