I think that this causing overflow:
DEBUG 13,10, "598", 1310
Comma is missing.
So DEBUG can handle only byte, so 1310 = $51E and that is bigger then 1 byte.
So i suppose that DEBUG should be something like this
DEBUG 13,10, "598", 13,10
Just find in PBP 1310, and insert comma...
EDIT: I just read first few post's