Move bash functions into individual files.
Reorder bash bam script after functions.
Use find and sort to find files at all levels.

Sort is necessary so the execution order is predictable.