Adding cleanup and build function