Updated with most recent plugin code