Cleaned up code based on feedback.