Removed various bugs, extended unit test, added performance test