Remove unused import
Fix bug in length encoding