Explicitly defined functions, Made function calls more explicit

Will allow it to be run directly from Matlab
Copied log file over each time it was edited

Otherwise link on website wouldn't give details on why it crashed