Fix compile errors and add export script