Extracted icon generation code.
Whitespace cleanup.
Added alter hooks + API docs. Fixed minor things.