Final Commit

Commited the final code with comments where needed. I believe it is
pretty self-explanatory