Documented some stuff. Mostly added comments and rearranged code for readability.