(Runs, but not working): Fix major bugs causing crashes