refactored & fixed plugin signals

I fixed a problem with loaddata and the plugin signals (#3351) and refactored the code.