Abolishing somne global variables and moving procedures into other procedures