Simplify code of MainWindow. Unify some barcode stuff.