added handling of binary files and debug switch