adding flattenning preview
debugging so that panel shows up
debugging further
minor refactoring
minor refactoring 2
added debug prints to figure out bugs in preview