Adding halo id, improved force minimizig function