Cleaned up code 

Still not completely done but cleaned up code a little more and added more comments