move out mag_log_ui and mag_binpow_uiui and document them