add head, tail and ptools stuff

Signed-off-by: Mattias Andrée <maandree@operamail.com>