Fix constant crashing bugs

Totally reworked the export images and states. Crashes cause because of:
- Accessing className instead of class. e.g. [object class] ==
‘MSLayerGroup’
- Too many loops inside of each other
- Removed all global variables except one. Would like to get rid of
that eventually too.

New approaches:
- Add * in order to not flatten, flattening is the default

Casualties:
-CSS export support
- Probably some optimizations