Fix differents things in the source code thanks to Neamar comments
Upgrade should from 3.1.x to 4.x