Fix unspecified behaviour in API