Removed some of the useless parameters, tuned some values and reordered it to declare objects before they are referred to.