Update doc
Remove unused functions/macros
Fix cosmetic errors