Bug fixes and added detailed perf tests.