Should fix a bunch of bugs