Add code in an attempt to support android. Not quite there though (mysterious segfaults)