log functions moved to log_fn, more minor improvements, beginning work on penalty function