Fix awful library usage and local variables definitions.