A lot of changes: debug and add a trig library