move Lua console creation code into separate console.lua, cleanup a bit