Various changes

1.  Fix on preview image fir inside DIV
2.  Fix on ID generation: make different paths for DEBUG and RELEASE
3.  Some unused code cleanup