Fixed some node replacement
Started function nearest node detection