add debug flag, update usage and make script work with ruby 1.8+