Brought the code more in line with the android code.