Improved code slightly.