Android v4 support from v2 branch, and bug fixes