lib/ tidy and document