Cleaned up code by adding comments to addToSystem and below, and changing names of some variables for better readability