Segmentize more code. Implement optargs. Some tests fail though