Adjusted the build script behavior

Removed some absolute path, and refactored the code so
it handles the nested folder archives
Removed unused function