Start of port to android
Some cleanup