diff --git a/accounts/scwallet/hub.go b/accounts/scwallet/hub.go
index 475305101acc65772d27ad166fcf85a3922a6be5..c259f711f0bc1700d54fda117707ee03ba352b22 100644
--- a/accounts/scwallet/hub.go
+++ b/accounts/scwallet/hub.go
@@ -36,6 +36,7 @@ import (
 	"encoding/json"
 	"io/ioutil"
 	"os"
+	"path/filepath"
 	"sort"
 	"sync"
 	"time"
@@ -111,10 +112,11 @@ func (hub *Hub) readPairings() error {
 }
 
 func (hub *Hub) writePairings() error {
-	pairingFile, err := os.OpenFile(filepath.Join(hub.datadir,"smartcards.json"), os.O_RDWR|os.O_CREATE, 0755)
+	pairingFile, err := os.OpenFile(filepath.Join(hub.datadir, "smartcards.json"), os.O_RDWR|os.O_CREATE, 0755)
 	if err != nil {
 		return err
 	}
+	defer pairingFile.Close()
 
 	pairings := make([]smartcardPairing, 0, len(hub.pairings))
 	for _, pairing := range hub.pairings {
@@ -130,15 +132,11 @@ func (hub *Hub) writePairings() error {
 		return err
 	}
 
-	return pairingFile.Close()
+	return nil
 }
 
 func (hub *Hub) pairing(wallet *Wallet) *smartcardPairing {
-	if pairing, ok := hub.pairings[string(wallet.PublicKey)]; ok{
-		return &pairing
-	}
-	return nil
-	if ok {
+	if pairing, ok := hub.pairings[string(wallet.PublicKey)]; ok {
 		return &pairing
 	}
 	return nil
@@ -209,6 +207,7 @@ func (hub *Hub) refreshWallets() {
 		// want to fill the user's log with errors, so filter those out.
 		if err.Error() != "scard: Cannot find a smart card reader." {
 			log.Error("Failed to enumerate smart card readers", "err", err)
+			return
 		}
 	}
 	// Transform the current list of wallets into the new one
diff --git a/accounts/scwallet/securechannel.go b/accounts/scwallet/securechannel.go
index 3c97321982d5d6a987e3a6cb0f49daf6e7a57a6a..fad876a019c08ce94f8ddb3ee0a8c2c0e3dc2df1 100644
--- a/accounts/scwallet/securechannel.go
+++ b/accounts/scwallet/securechannel.go
@@ -229,8 +229,8 @@ func (s *SecureChannelSession) transmitEncrypted(cla, ins, p1, p2 byte, data []b
 	if err != nil {
 		return nil, err
 	}
-	meta := []byte{cla, ins, p1, p2, byte(len(data) + scBlockSize), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
-	if err = s.updateIV(meta, data); err != nil {
+	meta := [16]byte{cla, ins, p1, p2, byte(len(data) + scBlockSize)}
+	if err = s.updateIV(meta[:], data); err != nil {
 		return nil, err
 	}
 
@@ -249,7 +249,7 @@ func (s *SecureChannelSession) transmitEncrypted(cla, ins, p1, p2 byte, data []b
 		return nil, err
 	}
 
-	rmeta := []byte{byte(len(response.Data)), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+	rmeta := [16]byte{byte(len(response.Data))}
 	rmac := response.Data[:len(s.iv)]
 	rdata := response.Data[len(s.iv):]
 	plainData, err := s.decryptAPDU(rdata)
@@ -257,7 +257,7 @@ func (s *SecureChannelSession) transmitEncrypted(cla, ins, p1, p2 byte, data []b
 		return nil, err
 	}
 
-	if err = s.updateIV(rmeta, rdata); err != nil {
+	if err = s.updateIV(rmeta[:], rdata); err != nil {
 		return nil, err
 	}
 	if !bytes.Equal(s.iv, rmac) {