Some correction to android stuff and buffer management