Cosmetic changes

Remove trailing spaces
No changes in logic
Performance improvement for shared resources

Substantial performance improvement for systems with Shared=YES or FORCE
and large numbers of running jobs (replace bubble sort with quick sort).
Bug 525
Remove redundant variables

This eliminates some now redundant arrays and variable copying
introduced in commit 74d1a4b4c95b7a860ffe1649613d2a589cf9a5d6
bug 525