finish general program flow and fix bugs

bug fixes mostly relate to replacing self and copying packages