Cleaned up MATE code