clean up keywords and use flags