fix issues pointed by Morteza and Andrea
fix conflicts