Inline docs & improved validity checking