Added memory stats and fixed bug. Closes #1