Various fixes for LuaTeX compatibility