Yeah at this point a rewrite was better for my sanity!