Updated crypto (plus a few fixes)

What do you think? (I moved -lm because it has to be linked before Lua)