Added comments, removed magic numbers