Adding preloader, code cleanup.

Adding preloader, code cleanup.