Refectoring of misc. and trig. functions