Added in options for analysis and cleaned up the logic a little