Loads of Android compatibility fixes