Split memory management

Some attempts to address #1079 -- just for discussion at this point.
It fixes a compiler warning about type conversion.  I'll add a comment.