Decoding works slightly better, fixed that bug. Still sometimes hits EOF at wrong time.