Fixed a couple of memory leaks
First steps towards a simple (POSIX inspired) error reporting model