Several Optimizations and Fixes

Fixed a small regression in C2DM and GCM caused by all the refactorings,
Added a max connection attempts to APNS, added connection timeout to
APNS, improved APNS performance a bit