Some changes to adapt plugin to 1.9
adapted the code to work in master version