This document presents a novel method for improving power quality in a distribution system connected to a microgrid using a flexible AC distribution system device. The device aims to compensate for harmonics, regulate voltage and frequency variations, and provide real and reactive power support during islanding operations of the microgrid. The control design employs a new model predictive control algorithm that separates the steady-state and transient control problems, reducing computational time. Detailed simulations in MATLAB are presented to demonstrate the capability of the proposed device to maintain high power quality in the distribution system and microgrid.