Change source layout, make package detection better, ...

For command documentation, allow the use of "main" unless
"documentation" is detected.