Reorganising code
Cleaned up code and renamed functions.
String trimming has been moved into an unnamed namespace.

Signed-off-by: Andrew Maclean <andrew.amaclean@gmail.com>