Added code to handle black samples.
Added more output and input options.