cleaning up and adding some functionality needed by cobra