Fixed errors with mages