Androidification

First stab at the library refactor. It seems to be working at least as well as before. Even if (/though) there are still a bunch more crashes, I think this is a better point to work from.