Improve the docs
Simplify pad lookup conditionals
Fix a memory leak