Better detection of battery being unplugged.
add geolocation stuff
geolocation added
reapplying @tollman's changes
Improve charging detection.
Improve charging detection.