Added comments and optimized

Removed unnecessary Finished variable. Also, added comments explaining
what each line does.