Major re-engineering using simplified shell script instead of ruby.