Fixed packet 6, temporary however. Also added encode.