Added plugin support and fixed some minor bugs