Made functions of the mess in window.onload function.