larger refactoring and added hexdump.