Graphite server: improve error handling.

Also improvements to tests, performance, modularity, removed dependency
on core.match, etc. Possibly fixes #338?