better handling of startup / cleanup