Added comments. Cleaned up useless code