FIX bugs and write a small part of trace