Cleaned up code for better organization.