Corrupted git ojbects, so a major commit below

Refactored many operational functions and removed old functions.

Code reuse is used throughout, with the exception of __prune().
Convert __prune() to new format

__prune(): Now uses reusable code