Moving some var to global scope. Improve time execution by 2.