Prefinal work. Changed functions and menu.