Do some reference counting.  Still a memory leak, but at least we are not accessing invalid memory
Add some io stuff
More attempts to do better memory management