Documentation, cleaned up code