refactored code for xamarin ios and some fixes for xamarin android