Bit of performance tweaking by Aparajita.