Fix bugs and make it work (hopefully like it should)