Substation multifix MK I

First half of my multifix, should fix all known code errors. Also includes suggestions.

#6257 
Yeah, this way you can see whole function on one screen, and it's much easier to see waht messages relates to which condition.