Restructured (added BinaryFunction structure) and increased speed