Migrated changes from LibDroid