Added code modifed from the android hive project