Make compilation script more robust