Fixed a bug, cleaned up a bit for readability
some quick notes and references