fixed random compile errors with cleanup