Reimplement QR decomposition. Add better documentation. Make id more generic.