Fixed warnings and exception catching.

May break if I've been too restrictive, but at least we'll find the errors right away and not keep them hidden :)