Trying to catch an error, better sanity checking all around

See https://github.com/GigaOM/legacy-pro/issues/2085

https://github.com/misterbisson/scriblio/commit/2d4d3e84d6943134e468176cf5e6b5f842f94bdb maybe will catch this, but I'm not entirely clear where the problem is. The best I can see is that the line number corresponds to `$before_link` inside the `sprintf()`. If `$before_link` is an object, it could totally cause the problem.

Also see https://github.com/GigaOM/legacy-pro/issues/2092 for some general warnings cleanup. Other, unticketed cleanup throughout.