Second round of memory leak fixes
Second round of memory leak fixes

This change is a bit more aggressive with avoiding holding onto stuff
for longer than necessary. This avoids creating the inMemoryInput in the
factory's NewInput() and instead creates it up-front. Then it *releases*
it in the NewInput(). Furthermore, once it's persisted, all the
memory-intensive elements of the input are released.

Fixes: #9

lhchavez/quark,lhchavez/quark