added support for scanning inverted barcodes; various other bugfixes