Added lots of documentation and fixed some stuff