Added merging, MAJOR cleanup, added comments and stuff