Script now works with Linux (Ubuntu 14.04 tested) and MacOS Mavericks