Added packlen function.