refactored to use at_start and at_exit, and re-implemented configatron