Add documentation and make scanning more flexible