fixed bugs and neatened code. BASH-based program now completed. (V0.2)