Fix compilation on Ubuntu

In case of any doubts ask makes inline comments to the code of the commit