Added more thorough documentation. TODO: Complete.