Refactored code to eliminate NetBeans warnings.