Index: /trunk/downstream.go
===================================================================
--- /trunk/downstream.go	(revision 439)
+++ /trunk/downstream.go	(revision 440)
@@ -314,5 +314,5 @@
 // ackMsgID acknowledges that a message has been received.
 func (dc *downstreamConn) ackMsgID(id string) {
-	netName, entity, _, _, err := parseMsgID(id)
+	netID, entity, _, err := parseMsgID(id)
 	if err != nil {
 		dc.logger.Printf("failed to ACK message ID %q: %v", id, err)
@@ -320,5 +320,5 @@
 	}
 
-	network := dc.user.getNetwork(netName)
+	network := dc.user.getNetworkByID(netID)
 	if network == nil {
 		return
Index: /trunk/msgstore.go
===================================================================
--- /trunk/msgstore.go	(revision 439)
+++ /trunk/msgstore.go	(revision 440)
@@ -2,4 +2,7 @@
 
 import (
+	"fmt"
+	"strconv"
+	"strings"
 	"time"
 
@@ -19,2 +22,18 @@
 	Append(network *network, entity string, msg *irc.Message) (id string, err error)
 }
+
+func formatMsgID(netID int64, entity, extra string) string {
+	return fmt.Sprintf("%v %v %v", netID, entity, extra)
+}
+
+func parseMsgID(s string) (netID int64, entity, extra string, err error) {
+	l := strings.SplitN(s, " ", 3)
+	if len(l) != 3 {
+		return 0, "", "", fmt.Errorf("invalid message ID %q: expected 3 fields", s)
+	}
+	netID, err = strconv.ParseInt(l[0], 10, 64)
+	if err != nil {
+		return 0, "", "", fmt.Errorf("invalid message ID %q: %v", s, err)
+	}
+	return netID, l[1], l[2], nil
+}
Index: /trunk/msgstore_fs.go
===================================================================
--- /trunk/msgstore_fs.go	(revision 439)
+++ /trunk/msgstore_fs.go	(revision 440)
@@ -37,26 +37,32 @@
 }
 
-func parseMsgID(s string) (network, entity string, t time.Time, offset int64, err error) {
+func parseFSMsgID(s string) (netID int64, entity string, t time.Time, offset int64, err error) {
+	netID, entity, extra, err := parseMsgID(s)
+	if err != nil {
+		return 0, "", time.Time{}, 0, err
+	}
+
 	var year, month, day int
-	_, err = fmt.Sscanf(s, "%s %s %04d-%02d-%02d %d", &network, &entity, &year, &month, &day, &offset)
-	if err != nil {
-		return "", "", time.Time{}, 0, fmt.Errorf("invalid message ID: %v", err)
+	_, err = fmt.Sscanf(extra, "%04d-%02d-%02d %d", &year, &month, &day, &offset)
+	if err != nil {
+		return 0, "", time.Time{}, 0, fmt.Errorf("invalid message ID %q: %v", s, err)
 	}
 	t = time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.Local)
-	return network, entity, t, offset, nil
-}
-
-func formatMsgID(network, entity string, t time.Time, offset int64) string {
+	return netID, entity, t, offset, nil
+}
+
+func formatFSMsgID(netID int64, entity string, t time.Time, offset int64) string {
 	year, month, day := t.Date()
-	return fmt.Sprintf("%s %s %04d-%02d-%02d %d", network, entity, year, month, day, offset)
+	extra := fmt.Sprintf("%04d-%02d-%02d %d", year, month, day, offset)
+	return formatMsgID(netID, entity, extra)
 }
 
 // nextMsgID queries the message ID for the next message to be written to f.
-func nextMsgID(network *network, entity string, t time.Time, f *os.File) (string, error) {
+func nextFSMsgID(network *network, entity string, t time.Time, f *os.File) (string, error) {
 	offset, err := f.Seek(0, io.SeekEnd)
 	if err != nil {
 		return "", err
 	}
-	return formatMsgID(network.GetName(), entity, t, offset), nil
+	return formatFSMsgID(network.ID, entity, t, offset), nil
 }
 
@@ -65,9 +71,9 @@
 	fi, err := os.Stat(p)
 	if os.IsNotExist(err) {
-		return formatMsgID(network.GetName(), entity, t, -1), nil
+		return formatFSMsgID(network.ID, entity, t, -1), nil
 	} else if err != nil {
 		return "", err
 	}
-	return formatMsgID(network.GetName(), entity, t, fi.Size()-1), nil
+	return formatFSMsgID(network.ID, entity, t, fi.Size()-1), nil
 }
 
@@ -114,5 +120,5 @@
 	}
 
-	msgID, err := nextMsgID(network, entity, t, f)
+	msgID, err := nextFSMsgID(network, entity, t, f)
 	if err != nil {
 		return "", fmt.Errorf("failed to generate message ID: %v", err)
@@ -374,11 +380,12 @@
 	var afterOffset int64
 	if id != "" {
-		var idNet, idEntity string
+		var idNet int64
+		var idEntity string
 		var err error
-		idNet, idEntity, afterTime, afterOffset, err = parseMsgID(id)
-		if err != nil {
-			return nil, err
-		}
-		if idNet != network.GetName() || idEntity != entity {
+		idNet, idEntity, afterTime, afterOffset, err = parseFSMsgID(id)
+		if err != nil {
+			return nil, err
+		}
+		if idNet != network.ID || idEntity != entity {
 			return nil, fmt.Errorf("cannot find message ID: message ID doesn't match network/entity")
 		}
