rearranged some code, fixed the rightclick menus