Code is now actually fast and parallel. Energy function used 99% of the time