Fix minor compiler warnings due to implicit casts
Properly detect failure to open logs. Avoid trying to write on failure.
Fix format string bug in the example
Add build.sh and clean.sh for easier building