tools: lots of fixes

Signed-off-by: Robert Nelson <robertcnelson@gmail.com>