Plugin error on activation – breaks page encoding and prints the code of plugin php files

Tried everything, finally rebuilt the plugin from ground up, split into several smaller ones. Installed and activated one by one and the problem was fixed. Everything works now.