Fix Bug in trace.c. If ringbuffer is full, we don't write to ringbuffer again now. And do some small refactorings, const definitions etc