fixed code and preview.sh, removed some warnings