A first working version of the position correlation function. Probably buggy...