issue #30 major refactoring - pull common functions into tools library. Added / fixed some big mission regression tests.