Fix typos

Fix some typos in C++ and Lua, remove trailing whitespace (my git config does this automatically).