Added support for parsing from file and removed memory leaks