Rewrote slow parts in fortran, three-body still wrong, and PBC does not work right