tighten up code and docs