Improve build and remove redundant code