Improve deserialization on Android, see Issue #131,
credit goes to Jan Sileny and original authors