refactored MainTemplate to plugin interface
fixed some issues