Rearrange directory structure and implement trace macros