refactored to support config gui stuff