Attempts at code tidyup
Improved component checking
Now saves state vars and params to file at end of simulation run