Bug fixes: memory leak