fix a bunch of bugs

sort of working now...