Major cleanup + doc.