android version adopted from vad branch
clean up