Handling state chunks in memory is now addressed. Cleaning up code