Used references instead of values and fixed some style

Input arguments in prototypes have been passed by reference.
Some minor style issues, as library inclusion order, have been
fixed as well.

Signed-off-by: Raffaele Aquilone <aquiloneraf@gmail.com>