Fix tests, re-add scripts
Refactor and whitespace