Added flags. Made lots of safety improvements. It should pretty much never die anymore. Now really need to add logging for all those exceptions I could be hiding.