Fixes for two-stage build and cleanup.