Cleaned up source and commented