Made the preview update faster and some small code cleanup