fix a million stupid bugs and make it actually work