cleanup code to be more readable (add pswarpStatsFile structure, pswarpCleanup, move code into pswarpDefineBackground and pswarpLoopBackground