Code refactoring: deleted some unnecessary code.
Made the validation of the scanned barcode more robust.

Also some more code refactoring.