better exception handling, added verbose flag to control output, corrected parsing of NAs, fix potential divide by 0