Added options processing via optparse. Added threading option.