Added plugin api. Closes #177.