Refactor and clean up barcode api