Fixed NPE when flattening (Closes #1). Added toggle focus action