Cleaner code, some more comments, fixed errorMargin