Code cleanup and added leftover docs.