Added namespaces support (fixes #1)
Fixed memory leaks