Finalized

Added comments, some bugs were found and fixed, slight optimization and
clearing unnecessary code