(s,S) Periodic, P-dist completed

And som cleaning of code done.