Improve efficiency, add commands, thread safety.