Removed some bugs; in the process of making log_sum_exp numerically robust