Cleaned up code, added modified agg-cat