Improved build script with comments and cleanup