Improved logging
State is now saved upon exit