Cleaned up codes