Fix a bunch of problems. I am sure there are better ways of doing this, but it works for now