This isn't the final one, still adjusting to make sure logic in comments
are correct. If anything please check over the code and notify me if
there is anything wrong once I commit the final changes.