revised plugin code, housekeeping a bit.