reorganize, add doc comments