Made the preview load in another window and other improvement and bug fixes