Refactor

Miscellaneous Refactoring. No major updates to scripts.