Clean up and documenting of code