Added stricter g++ flags and fixed compile warnings.
Fixed a few memory leaks.
Added doxygen comments where possible.