Added error handler to Main.R.  Replaced many of the for loops in the program with while loops (fixes an issue where loops ran for longer than they shoud).  Changed checkParams() to set default values (for certain values) instead of throwing errors.