Modularized scripts + fixed a few bash code smells