Refactors code for clarity, updates doc block.