Improve build function; add greptype function