Removed utility function logf and changed cmd functions to return an error value rather than an error code.
Change a few prints to go to stderr, and avoid printing duplicate error message for the unknown command error.
Refactor main to remove unnecessary else statement
Merge pull request #219 from Moghedrin/master

Fix atypical error handling in `cmd` functions.