refactoring and tidying also finished riot server final bits