Tests pass; ugly stuff, though