Refactor and doc changes