Major refactoring of the redinzanes bed plugin