Corrected set up
Removed unnecessary defines
Neatened up the code.

Doxygened the hell out of it