add debug feature, add commands, optimize