Cleaning up and documentation

	* cleaning up code and documenting
	* adding TODO where needed