Refactor more on buildex and fix some bugs