Minor refactoring. Still not executing the last few lines of the script though. Odd.