Remove debug prints, change onexit to atexit