Fix packet default length and clean up error handling