added comments over the confusing things, organized the code a bit, cut down on some unneeded code