Removed debug code.
Fixed compiler warning (-Wformat).
Fixed memory errors (fixes #24).
Fixed various memleaks.