Revamped core and added unittests