Added docs
Simplified a macro
Added missing functions and tests