Added remainder test
Minor code cleanup and formatting.
Wrote extensive documentation.
Removed trailing space and superfluous variable.
Added TODOs.