Move library headers, add backtrace, fix log