Improved error logging. Add -debug flag.
group up some vars. go fmt.