Cleaned up and commented.