fixed gui, added optimizations