Fixed total energy conservation problem when attaching to a track, see #141