Remove trailing whitespaces in .h, .cpp, .c and .lua files.
Various cleanups in some C++ files.
Add a script to check whether files in the working directory have trailing whitespaces.
Add a rule in Travis to check for trailing whitespaces.