There are a lot of magic numbers in this code. Remove them, if possible; define them, if there's a succinct name; explain them, if necessary.