proper deinitialization and wrappers to do so, special main stuff for proper deinitialization if bad stuff happens so more bad stuff doesn't happen