adds some checks to remove generated files on build