Some fixes

Thanks to adfad666 for Gsensor patch.