Transplant general stuff from moodie into android lib