Fixed some return value bugs