Done some Error checking
Modified plugin architecture.