fixes

rewrote cos_critical, fxed signs...