improve code a bit
add missing header
fix format string warnings
Merge branch 'master' into portable
send paths defined by configure switches to all Makefile.am. Fix #348