Style tweaks; added comments; renamed some variables