Upgrade to the latest version of doctrine.
Merge pull request #694 from briandipalma/doctrine-to-0.5

Upgrade to the latest version of doctrine. (Fixes #661 and fixes #689)