Fix length prefix issue
Don't break when a folder is shared
Flake8 fixes