Made the code a little more "flat", which should look less complex.
Fixes for CLANG giving some valid warnings and added an #include for Mac OS X as proposed in Issue #18.
Removed an unused variable.