Changed some things
Added some comments and fixed some bugs