optimized build settings. fixed a cleanup code ordering problem