Improve build function.