Refactor numerous functions to be within piece-specific namespaces;
refactor some functions to make use of the newly included namespaces; amend function names;
rewrite some comments.