Add some sectioning comments
Detect external program availability upon import
Split code to have one function per external program

This will ease testing.