Code cleanup and slight performance improvement.