Fixed the coincident point handling and explicitly casted s