Cleanups to the living level

This more clearly modularizes the code while avoiding side effects.