avoid duplication of input dirs, plus some cleaning
Add link library otherwize do not compile with gcc 4.3.2