Move compilation out of main