Reorg and cleanup

Reorganized the message handlers into a map of functions, split the randstr function to a new package as it can stand alone.