Improved efficiency / Added more test cases.