Main code restructure to use plmd base class

Moves some of the common functions used by all plmd modules to a base
class and inherits from that