simplify and cleanup plugin a bit