Better length checks for write / send calls