Fix some warnings and implement gradient heuristic in rust