formatted errors, factored code

additions to #128 . I probably forgot to update the src/ at the very end, shit.