Fix compilation on Ubuntu

In case of any doubt make inline comments to the code of the commit