Clean up. Use log module. Add cfg file and move some setting to cfg.