Plugin resize fixes

This pull request fixes a couple of bugs and improves code quality.

CC @anselmh @melros