big ass rewrite, everything works now