Export function + some fixes