Edited to make threshold ratio a command-line option.