refactored modal layout
events and a lot of others