Fixes #1623
Fixes #1623
Fixes #1717
Fixes #1718
Small improvement
Proper logic, thanks to Guillaume
Fix the size of ByteBuffer
Fix Atmosphere/atmosphere#1720