Added special cases, fixed return values