Better documentation; code cleanup