Tweak all headers, add new commands, generalize utils, improve testability.