Code cleanup as per dhermes' suggestions.