Change the places of some functions and etc...

Change the places of som functions.
Hotfix "Preview" bug.