Reorganized code; update performance test