Making some stuff local.
Should decrese the number of clls to global functions. In theory that will give us a slight perfomance increase.